package com.wigem.approve.controller;

import com.wigem.framework.common.pojo.PageResult;
import com.wigem.framework.common.util.web.response.Result;
import com.wigem.framework.common.util.web.response.ResultController;

import java.util.List;

import com.wigem.approve.entity.DicEstateEntity;
import com.wigem.approve.service.DicEstateService;
import com.wigem.approve.vo.DicEstateVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.swing.text.html.parser.Entity;

/**
 * 楼宇字典Controller
 *
 * @author DH
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/approve/dicEstate")
public class DicEstateController extends ResultController {


    @Resource
    private DicEstateService dicEstateService;

    /**
     * 查询楼宇字典列表
     */
    @ResponseBody
    @GetMapping("/query")
    public Result getList(DicEstateVo dicEstateVo) {

        return success(dicEstateService.getList(dicEstateVo));
    }

    /**
     * 查询楼宇字典列表
     */
    @ResponseBody
    @GetMapping("/query/page")
    public Result getPageList(DicEstateVo dicEstateVo) {
        PageResult<DicEstateEntity> pageInfo = dicEstateService.getPageList(dicEstateVo);
        return success(pageInfo);
    }

    /**
     * 查询楼宇字典实体
     */
    @ResponseBody
    @GetMapping("/query/{id}")
    public Result getEntity(@PathVariable("id") String id) {
        return success(dicEstateService.getEntity(id));
    }


    /**
     * 楼宇字典新增
     */
    @ResponseBody
    @PostMapping
    public Result add(@RequestBody DicEstateVo dicEstateVo) {
        dicEstateService.add(dicEstateVo);
        return success("保存成功");
    }

    /**
     * 楼宇字典修改
     */
    @ResponseBody
    @PutMapping
    public Result update(@RequestBody DicEstateVo dicEstateVo) {
        dicEstateService.update(dicEstateVo);
        return success("修改成功");
    }


    /**
     * 新增保存
     */
    @ResponseBody
    @PostMapping("/save")
    public Result save(@RequestBody DicEstateVo dicEstateVo) {
        dicEstateService.save(dicEstateVo);
        return success("保存成功！");
    }


    /**
     * 删除
     */
    @ResponseBody
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        dicEstateService.delete(id);
        return success("删除成功！");
    }

    /**
     * 移除/逻辑删除
     */
    @ResponseBody
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable("id") String id) {
        dicEstateService.remove(id);
        return success("删除成功！");
    }
}
